package com.cw.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cw.dto.PatientAreaDTO;
import com.cw.entity.HisCwglDept;
import com.cw.mapper2.HisCwglDeptMapper;
import com.cw.request.EmptyBedsRequest;
import com.cw.service.IHisCwglDeptService;
import com.cw.util.StringUtil;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author smq
 * @since 2021-05-05
 */
@Service
public class HisCwglDeptServiceImpl extends ServiceImpl<HisCwglDeptMapper, HisCwglDept> implements IHisCwglDeptService {

    /**
     * 获取特定科室列表
     *
     * @param emptyBedsRequest
     * @return
     */
    @Override
    public Object getDeptList(EmptyBedsRequest emptyBedsRequest) {
	  List<HisCwglDept> hisCwglDeptList = baseMapper.getDeptList(emptyBedsRequest);
	  return hisCwglDeptList;
    }

    @Override
    public Object getDeptListByYard(String yard) {
        List<HisCwglDept> hisCwglDeptList = baseMapper.getDeptListByYard(yard);
        return hisCwglDeptList;
    }

    /**
     * 获取全部科室列表
     *
     * @param emptyBedsRequest
     * @return
     */
    @Override
    public Object getAllDeptList(EmptyBedsRequest emptyBedsRequest) {
        List<HisCwglDept> hisAlllDeptList = baseMapper.getAllDeptList(emptyBedsRequest);
        return hisAlllDeptList;
    }

    /**
     * 通过科室主键获取病区集合
     * @param deptCode 科室主键
     * @return java.util.List<com.cw.dto.PatientAreaDTO>
     * @author ly
     * @date 2021/5/13 17:09
     */
    @Override
    public List<PatientAreaDTO> getPatientAreaDTO(String deptCode,String areaCode,String yard) {
        if (StringUtil.isEmpty(deptCode)) { deptCode = null; }
        if (StringUtil.isEmpty(areaCode)) { areaCode = null; }
        if (StringUtil.isEmpty(yard)) { yard = null; }
        return baseMapper.getPatientArea(deptCode, areaCode,yard);
    }

    @Override
    public List<HisCwglDept> getHisCwglDeptByAreaCode(String areaCode, String yard) {
        if(areaCode.isEmpty())
        {
            return baseMapper.getDeptListByYard(yard);
        }
        return baseMapper.getHisCwglDeptByAreaCode(areaCode,yard);
    }

    /**
     * 院前准备中心-科室数据
     * 有权限判断的
     * @return java.util.List<com.cw.entity.HisCwglDept>
     * @author ly
     * @date 2021-09-03
     */
    @Override
    public List<HisCwglDept> getHisCwglDeptByUserAccess(String yard) {
        List<HisCwglDept> deptNameFromVYqBrdjxxTable = new ArrayList<>();
        HisCwglDept hisCwglDept = new HisCwglDept();
        hisCwglDept.setDeptName("全部");
        hisCwglDept.setDeptCode("all");
        deptNameFromVYqBrdjxxTable.add(hisCwglDept);
        deptNameFromVYqBrdjxxTable.addAll(baseMapper.getDeptNameFromVYqBrdjxxTable(yard));
        return deptNameFromVYqBrdjxxTable;
    }


}
